aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/(profile)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-17 11:29:01 -0800
committerAdam Soltys <[email protected]>2023-02-17 11:29:01 -0800
commitc3b6d3fe460392a9333049491577f8b6c19cfcfa (patch)
treeeea9013c5de1473eb962c85cc837060bdff004e6 /src/routes/(app)/[username]/(profile)
parentaa58352ad3ad79d6aae07e38a85d7ab41212b2a2 (diff)
downloadcoinos-ui-c3b6d3fe460392a9333049491577f8b6c19cfcfa.tar.gz
coinos-ui-c3b6d3fe460392a9333049491577f8b6c19cfcfa.zip
message styles
Diffstat (limited to 'src/routes/(app)/[username]/(profile)')
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.svelte24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte
index bc19a9df..4d4f3b13 100644
--- a/src/routes/(app)/[username]/(profile)/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/+page.svelte
@@ -4,6 +4,7 @@
import { t } from '$lib/translations';
import { f, sat, sats } from '$lib/utils';
import { sign, send, encrypt, decrypt } from '$lib/nostr';
+ import { event as e, password } from '$lib/store';
import { browser } from '$app/environment';
export let data;
@@ -13,8 +14,25 @@
let latest = [];
let i = 0;
- onMount(async () => {
- if (!browser) return;
+ e.subscribe(async (event) => {
+ if (event?.recipient.id === user.id && !~latest.findIndex((m) => m.id === event.id)) {
+ event.content = await decrypt({ event, user });
+
+ let i = latest.findIndex((m) => m.pubkey === event.pubkey);
+
+ if (~i) latest.splice(i, 1);
+ else latest.pop();
+
+ console.log(latest);
+ latest.unshift(event);
+
+ latest = latest;
+ }
+ });
+
+ $: initialize($password);
+ let initialize = async (p) => {
+ if (!p) return;
while (latest.length < 3 && i < messages.length) {
let event = messages[i];
let k = event.author.id === user.id ? event.recipient.pubkey : event.author.pubkey;
@@ -27,7 +45,7 @@
}
latest = latest;
- });
+ };
</script>
<div class="space-y-8">